<%--
  Created by IntelliJ IDEA.
  User: 南苼
  Date: 2021/7/4
  Time: 10:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
  <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
  <link rel="stylesheet" href="../css/edit.css">
  <script>
    $(function(){
      if(getUrlParam("name")!=null){
        localStorage.removeItem("name");
        localStorage.removeItem("zf");
        localStorage.removeItem("con");
        localStorage.setItem("zf",getUrlParam("fra"));
        localStorage.setItem("name",getUrlParam("name"));
      }
      $(".name").html(localStorage.getItem("name"));
      $(".fra").html(localStorage.getItem("zf"));
      $(".title").hover(function(){
        $(this).find(".deltimu").css("display","block");
        $(this).find(".updtimu").css("display","block");
      },function(){
        $(this).find(".deltimu").css("display","none");
        $(this).find(".updtimu").css("display","none");
      });
      $(".d4_1").delegate(".img2","click",function(){
        $(".name").html(" ");
        $(".img2").remove();
        var txt="<div class='txt'><input type='text' value='"+localStorage.getItem("name")+"' style='width: 450px;height: 30px;margin-left: 200px;'/>"+
                "&nbsp;&nbsp;<span>✔保存</span>&nbsp;&nbsp;<span class='qx'>╳取消</span></div>";
        $(".d4_1").append(txt);
      })
      $(".d4_1").delegate(".qx","click",function(){
          $(".name").html(localStorage.getItem("name"));

        $(".txt").remove();
        $(".img2").remove();
        var txt="<img src='../img/examimg/bjm.PNG' class='img2'>";
        $(".d4_1").append(txt);
      })
      $(".d4_3_1").click(function(){
        $.ajax({
          url:"http://localhost:9090/Eventstar/settings_zw/addedit.jsp",
          success:function(obj){
              $("#ad").html(obj);
          }
        })
      })
      $(".updtimu").click(function(){
        localStorage.setItem("con","2");
        var con=$(".fs");
        var sum=0;
        for(var i=0;i<con.length;i++){
          sum=sum+parseFloat($(con[i]).val());
          if($(con[i]).val()==0){
            localStorage.setItem("con","1");
          }
        }
        $(".zf").html(sum);
          var id=$(this).attr("qid");
          console.log(id);
        $.ajax({
          url:"http://localhost:9090/Eventstar/cho/up",
          data:{"q_id":id,"fs":$(".fs").val()},
          success:function(obj){

          }
        })
      })
      $(".deltimu").click(function(){
        var id=$(this).attr("qid");
        console.log(id);
        $.ajax({
          url:"http://localhost:9090/Eventstar/cho/del",
          data:{"q_id":id},
          success:function(obj){
            window.location.href ="settings.jsp?URL=settings_zw/edit.jsp";
          }
        })
      })
    })
    function getUrlParam(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
      var r = window.location.search.substr(1).match(reg);  //匹配目标参数
      if (r != null) return unescape(r[2]); return null; //返回参数值
    }
  </script>
</head>
<body>
<div class="d1">
  <div class="d2">
    <img src="/Eventstar/img/examimg/sz.PNG" class="img1">
  </div>
  <div class="d4">
    <div class="d4_1"><span class="name"></span><img src='/Eventstar/img/examimg/bjm.PNG' class='img2'></div>
    <div class="d4_2">
      <div class="d4_2_1"><h5>(总分<spans class="fra"></spans>)一.栏目标题（<span class="zf">0</span>分）|</h5></div>
      <div class="d4_2_2"><img src="/Eventstar/img/examimg/bj.PNG"></div>
      <div class="d4_2_2"><img src="/Eventstar/img/examimg/sc.PNG"></div>
      <div class="d4_2_3"><img src="/Eventstar/img/examimg/tj.PNG"></div>
    </div>
    <div style="background-color: white;width: 900px">
        <c:forEach items="${GETTM}" var="t">
          <div class="title">
            <br>&emsp;
              <input type="hidden"  class="qid" value="${t.q_id}">
           &nbsp; <input type="checkbox" name="inp"  style="display: none;">&nbsp;<span class="timu">${t.q_name}</span>
            <br><br><span class="opt">A、</span>${t.q_a}
            <br><br><span class="opt">B、</span>${t.q_b}
            <br><br><span class="opt">C、</span>${t.q_c}
            <br><br><span class="opt">D、</span>${t.q_d}
            <br><br><span class="opt">答案：</span>${t.q_answer}
           <div style="position: absolute;margin-left: 680px;margin-top: -240px;">（<input type="text" value="0" class="fs">分）</div>
            <div class="deltimu" qid="${t.q_id}"> </div>
            <div class="updtimu"qid="${t.q_id}"> </div>
          </div>
        </c:forEach>
    </div>
    <div id="ad"></div>
    <div class="d4_3">
      <div class="d4_3_1"><img src="/Eventstar/img/examimg/tjx.PNG"></div>
      <div class="d4_3_2"><a href="/Eventstar/settings_zw/choose.jsp"><img src="/Eventstar/img/examimg/tk.PNG"></a></div>
      <div class="d4_3_3"><img src="/Eventstar/img/examimg/jtlm.PNG"></div>
    </div>
  </div>
</div>
</body>
</html>
